home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2010 Summer - Disc 1 / WN_Ete2010_CD1.iso / Onglet5 / Weezo / Weezo setup.exe / {code_appDir} / www / local / serverManagement.php < prev    next >
PHP Script  |  2010-05-19  |  4KB  |  151 lines

  1. <?php
  2. /**
  3.  * Process commands sent by weezo application
  4.  *
  5.  * PHP version 5
  6.  *
  7.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  8.  * that is available through the world-wide-web at the following URI:
  9.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  10.  * the PHP License and are unable to obtain it through the web, please
  11.  * send a note to license@php.net so we can mail you a copy immediately.
  12.  *
  13.  * @category   NA
  14.  * @package    NA
  15.  * @author     Nicolas Bruley / Peer 2 World <contact@weezo.net>
  16.  * @copyright  2005-2009 Nicolas Bruley / Peer 2 World
  17.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  18.  * @version    CVS: $Id:$
  19.  * @link       http://www.weezo.net
  20.  * @since      File available since Release 1.0.5
  21.  */
  22.  
  23. ignore_user_abort(true);
  24.  
  25. // Initialize script data
  26. require_once('localFunctions.php');
  27. require_once(INCLUDE_DIR.'initFunctions.php');
  28.  
  29. /**
  30.  * Clear general.ini and languages data into server memory
  31.  */
  32. if(isset($_GET['resetConfig'])){
  33.     @cfMUnsetVar('weezoGeneral');
  34.     ifInitializeServer();
  35. }
  36.  
  37. /**
  38.  * Clear general.ini and languages data into server memory
  39.  */
  40. if(isset($_GET['resetGeneral'])){
  41.     @cfMUnsetVar('weezoGeneral');
  42.     ifLoadGeneral();
  43. }
  44.  
  45. /**
  46.  * Set mailslot index, used for mailslot communication with application
  47.  */
  48. if(isset($_GET['setMailslotIndex']) && is_numeric($_GET['setMailslotIndex'])) cfMSetVar('mailslotIndex',$_GET['setMailslotIndex']);
  49.  
  50. /**
  51.  * Set external IP address
  52.  */
  53. if(isset($_GET['setExternalIP'])) cfGUpdateVar('externalIP',$_GET['setExternalIP'],'serverOnly');
  54.  
  55. /**
  56.  * Ban IP address
  57.  */
  58. if(isset($_GET['banIP'])) {
  59.     
  60. }
  61.  
  62. /**
  63.  * Reset (only) user data into server memory
  64.  */
  65. if(isset($_GET['resetUsers'])){ifLoadUsers();}
  66.  
  67. /**
  68.  * Reset (only) resources data into server memory
  69.  */
  70. if(isset($_GET['resetResources'])){
  71.     if(isset($_GET['resourceFile'])) {
  72.         ifLoadResource($_GET['resourceFile']);
  73.         // Indicate UI resource tab web interface to focus on this resource at next reload
  74.         cfGUpdateVar("uiResourceSelected",$_GET['resourceFile']);
  75.     }
  76.     else ifLoadResources();
  77. }
  78.  
  79. /**
  80.  * Reset resources definition
  81.  */
  82. if(isset($_GET['resetResourcesDefinition'])){ifResourcesDefinitions();}
  83.  
  84.  
  85.  
  86. /**
  87.  * Reset all logged users from actually existing / associated resources
  88.  */
  89. if(isset($_GET['resetLoggedUsersResources'])){
  90.     ifResetResourcesUsers(false && isset($_GET['resetUsers']),false && isset($_GET['resetResources']));
  91. }
  92.  
  93. /**
  94.  * Clear in-memory and files sessions
  95.  */
  96. if(isset($_GET['destroySession']) && substr($_GET['destroySession'],0,5)=='sess_'){
  97.     @cfMUnsetVar($_GET['destroySession']);
  98.     @unlink(cfAppDataDir().'/sessiondata/'.$_GET['destroySession']);
  99. }
  100.  
  101. /**
  102.  * Update weezo.net account registration information
  103.  */
  104. if(isset($_GET['updateRegInfo'])) ifLoadRegInfo();
  105.  
  106.  
  107. // Start bittorrent seeder
  108. if(isset($_GET['bittorrentStart'])){
  109.     $handle=cfSocketHTTPRequest(cfGGetVar('protocol').'://127.0.0.1:'.cfGGetVar('serverPort').'/bittorrentSeeder.php?action=start',7,false,$err,$curl,false,true);
  110.     if(!$handle) return false;
  111.     usleep(10000);
  112.     fclose($handle);
  113. }
  114.  
  115. // Set key used for IU scripts access
  116. if(isset($_GET['setWeezoKey']) && $_SERVER['REMOTE_ADDR']=='127.0.0.1') {
  117.     customSetKey($_GET['setWeezoKey']);
  118.     echo 'key set';
  119. }
  120.  
  121. // Set password key
  122. if(isset($_GET['setPwdKey'])) cfMSetVar('weezoPwdKey',base64_decode($_GET['setPwdKey']));
  123.  
  124.  
  125. /**
  126.  * Set server state ('web' or 'lan')
  127.  */
  128. if(isset($_GET['serverState']) && ($_GET['serverState']=='web' || $_GET['serverState']=='lan'))
  129.     cfMSetVar('weezoServerState',$_GET['serverState']);
  130.  
  131.  
  132. /**
  133.  * Server shuting down: log event
  134.  */
  135. if(isset($_GET['serverShutdown'])){
  136.     cfLogEvent(cfCaption('activityWeezoStop',false,false,false,true),EVENT_SERVERSTATE,S_EVENT_OFF);
  137. }
  138.  
  139. /**
  140.  * Server starting (on web) for the 1st time since app launched: log
  141.  */
  142. if(isset($_GET['logStartEvent'])){
  143.     // Monitor event
  144.     if(cfIsRegistered()) {
  145.         $regInfo=cfMGetVar('weezoRegInfo');
  146.         $logCaption=cfCaption('apacheStartedWeb',false,false,false,true).cfCaption('genSeparator').DNS_SITE.'/'.$regInfo['regName'];
  147.     }
  148.     else $logCaption=cfCaption('apacheStartedWeb',false,false,false,true).cfCaption('genSeparator');
  149.     cfLogEvent($logCaption,EVENT_SERVERSTATE,((cfMGetVar('weezoServerState')=='web' || (@$_GET['serverState']=='web'))?S_EVENT_WEB:S_EVENT_LAN));
  150. }
  151. ?>